# coding: utf-8
'''
Lists are used to store multiple items in a single variable.
Lists are one of 4 built-in data types in Python used to store collections of data,
the other 3 are Tuple, Set, and Dictionary, all with different qualities and usage.
Lists are created using square brackets.
リストは、複数の項目を 1 つの変数に格納するために使用されます。
リストは、データのコレクションを格納するために使用される Python の 4 つの組み込みデータ型の 1 つです。
他の 3 つは、タプル、セット、および辞書で、すべて異なる品質と使用法を持っています。
リストは角括弧を使用して作成されます。
'''
a = ["IICA","IT solution","Global IT Business"]
print(type(a),a,len(a))
input("Enterで次へ")
#index
print(a[0], a[-1])
print(a[0:3])
input("Enterで次へ")
#for loop
a = ["IICA","IT solution","Global IT Business"]
for x in a:
print(x)
for i in range(0,len(a),1):
print(a[i])
input("Enterで次へ")
# 要素追加
a.append("南阿蘇")
print(a)
a.insert(0,"熊本県")
print(a)
a[-1] = "学生"
print(a)
input("Enterで次へ")
b = ["redapple","greenapple","yellowapple"]
print(b)
b[0:2] = ["赤リンゴ","緑リンゴ","黄リンゴ"]
print(b,len(b))
input()
fruits = ["apple", "banana", "cherry", "kiwi", "mango"]
newlist = []
for x in fruits:
if "a" in x:
newlist.append(x)
print(newlist)
newlist2 = [x for x in fruits if "a" in x]
print(newlist2)
input("Enterで次へ")
b = ["redapple","greenapple","yellowapple","banana","kiwi","watermelon","persimmon"]
print(b)
#要素削除
b.remove("redapple")
print(b)
b.pop(3)
print(b)
b.pop()
print(b)
del b[0]
print(b)
b.remove("yellowapple")
print(b)